package cn.iocoder.yudao.module.flgeo.dal.mysql.geoshp;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.flgeo.dal.dataobject.geoshp.GeoshpDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.flgeo.controller.admin.geoshp.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 图形 Mapper
 *
 * @author fl
 */
@Mapper
public interface GeoshpMapper extends BaseMapperX<GeoshpDO> {

    default PageResult<GeoshpDO> selectPage(GeoshpPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GeoshpDO>()
                .likeIfPresent(GeoshpDO::getName, reqVO.getName())
                .likeIfPresent(GeoshpDO::getRemark, reqVO.getRemark())
                .eqIfPresent(GeoshpDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(GeoshpDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GeoshpDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(GeoshpDO::getId));
    }

    default List<GeoshpDO> selectList(GeoshpExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GeoshpDO>()
                .likeIfPresent(GeoshpDO::getName, reqVO.getName())
                .likeIfPresent(GeoshpDO::getRemark, reqVO.getRemark())
                .eqIfPresent(GeoshpDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(GeoshpDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(GeoshpDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(GeoshpDO::getId));
    }

    @Update("UPDATE flgeo_geoshp set geom = ST_GeomFromGeoJSON(#{geom}) where  id = #{id} and  deleted = 0")
    void updateGeomById(@Param("id") Long id,@Param("geom") String geom);
}
